package com.ds.lens.flink.monitor.eventsinkjob.function.notify.onduty;

import com.google.gson.JsonObject;
import feign.Headers;
import feign.Param;
import feign.RequestLine;

/**
 * @author Gerald Kou
 * @date 2019-05-22
 * <p>
 */
public interface OndutyClient {

    @RequestLine("POST /api/v1/event")
    Reply sendAlarm(Notice message);

    @Headers({"Authorization: Basic {authorization}", "Accept: application/json"})
    @RequestLine("GET /api/v1/ticket/detail?ticketId={ticketId}")
    JsonObject getDetail(@Param("authorization") String authorization, @Param("ticketId") String ticketId);

    @Headers({"Authorization: Basic {authorization}", "Accept: application/json"})
    @RequestLine("POST /api/v1/ticket/comment")
    JsonObject appendComment(@Param("authorization") String authorization, Comment comment);

//    public static void main(String[] args) {
//        OndutyClient client = HttpServiceClient.getRestClient(OndutyClient.class, "http://172.20.160.36:8700");
//        String authorization = "YXBtLXB1c2g6YWlJY2hLdHJaVlM1MFBtSA==";
//        String ticketId = "case-f4042a8dac73";
//        JsonObject json = client.getDetail(authorization, ticketId);
//        System.out.println(json.getAsJsonObject("data").getAsJsonPrimitive("status").getAsString());
//        json = client.appendComment(authorization, new Comment(ticketId, "hello"));
//        System.out.println(json.get("message"));
//    }
}
